using System;

namespace FastSocket.SocketBase.Log
{
    public class ListenerWrapper : ITraceListener
    {
        private readonly Action<string> _onDebug = null;
        private readonly Action<string, Exception> _onError = null;
        private readonly Action<string> _onInfo = null;

        public ListenerWrapper(Action<string> onDebug,Action<string,Exception> onError,Action<string> onInfo)
        {
            if (onDebug == null) throw new ArgumentNullException("onDebug");
            if (onError == null) throw new ArgumentNullException("onError");
            if (onInfo == null) throw new ArgumentNullException("onInfo");
            this._onDebug = onDebug;
            this._onError = onError;
            this._onInfo = onInfo;
        }
        
        public void Debug(string message)
        {
            this._onDebug(message);
        }

        public void Error(string message, Exception ex)
        {
            this._onError(message, ex);
        }

        public void Info(string message)
        {
            this._onInfo(message);
        }
    }
}